<!DOCTYPE html>
<html lang="zh_CN">

<head>
   <#include "../common/header.ftl">
    <script src="/js/plugins/ckeditor/ckeditor.js"></script>

    <script>
        $(function () {

            //修改操作
            $(".updateBtn").click(function () {
                var id = $(this).data("id");
                $.get("/buy/status.do", {id: id}, function (data) {
                    if (data.success) {
                        window.location.reload();
                    } else {
                        //$.alert("对方没有购买,请勿");
                        $.messager.alert("温馨提示", "操作失败,该商品不是待发货状态")
                    }
                })

            });
            $('#status').select2();
            $('#status').select2({
                //当没有选择数据时,显示内容
                placeholder: '请选择所属状态',
                //当存在数据时,显示清楚按钮
                allowClear: true
            });
            $('#collect').select2();
            $('#collect').select2({
                //当没有选择数据时,显示内容
                placeholder: '请选择所属收藏',
                //当存在数据时,显示清楚按钮
                allowClear: true
            });
        });

    </script>
    <style>
        .select2 {
            width: 150px;
        }

        .select2 > span {
            width: 100% !important;
        }
    </style>
</head>
<body>

<div class="container " style="margin-top: 20px">
    <#include "../common/top.ftl">
    <div class="row">
        <div class="col-sm-3">
        <#--设置当前要回显当前菜单,必须在载人菜单前完成设置-->
            <#assign menu = "buy" >
           <#include "../common/menu.ftl">
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">购买管理</h1>
                </div>
            </div>

            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="/buy/list.do" method="post">
                <input type="hidden" id="currentPage" name="currentPage" value="1">
                <div class="form-group">
                    <label>关键字:</label>
                    <input type="text" class="form-control" name="keyword" value="${(qo.keyword)!}"
                           placeholder="请输入标题/副标题">
                </div>
                <label>状态</label>
                <div class="form-group select2">
                    <select class="form-control form-control-chosen fa fa-search" id="status" name="status">
                        <option value="1">待发货</option>
                        <option value="2">已发货</option>
                        <option value="3">待付款</option>
                    </select>
                    <script>
                        $("#status").val(${qo.status});
                    </script>
                </div>
                <label>收藏</label>
                <div class="form-group select2">
                    <select class="form-control form-control-chosen fa fa-search" id="collect" name="collect">
                        <option value="0">未收藏</option>
                        <option value="1">收藏</option>
                    </select>
                    <script>
                        $("#collect").val(${qo.collect});
                    </script>
                </div>
                <button type="submit" class="btn btn-primary" id="buyBtn">
                    <span class="glyphicon glyphicon-search"></span> 查询
                </button>
            </form>


            <table class="table table-striped table-hover">
                <tr>
                    <th>商品标题</th>
                    <th>用户</th>
                    <th>收货人名</th>
                    <th>下单时间</th>
                    <th>收货人电话</th>
                    <th>收货人地址</th>
                    <th>商品状态</th>
                    <th>collect</th>
                    <th>操作</th>
                </tr>
                <!--如果result不为空就迭代输出-->
                    <#if result??>
                        <#list result.list as entity>
                        <tr>
                            <td>${(entity.commodity.title)!}</td>
                            <td>${(entity.user.nickName)!}</td>
                            <td>${(entity.name)!}</td>
                            <td>${(entity.time?string("yyyy-MM-dd"))!}</td>
                            <td>${(entity.tel)!}</td>
                            <td>${(entity.site)!}</td>
                            <td>${(entity.statueName)!}</td>
                            <td>${(entity.collectName)!}</td>

                            <td>
                                <a role="button" class="btn btn-info btn-xs updateBtn" data-id="${entity.id}"
                                <span class="glyphicon glyphicon-pencil"></span> 发货
                                </a>
                            </td>
                        </tr>
                        </#list>
                    </#if>
            </table>
            <!--分页-->
            <#include "../common/page.ftl">
        </div>
    </div>
</div>

<script>

</script>

</body>

</html>